package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/*查询小王的权限*/
public class SELECT {
    public static void main(String[] args) {
        try(Connection connection = DBUtil.getConnection();)
        {
            Statement statement = connection.createStatement();
            String sql = "select m.name "+
                         "from user u join u_r ur on u.id=ur.uid "+
                         "join r_m rm on ur.rid=rm.rid "+
                         "join module m on m.id = rm.mid "+
                         "where u.name='小王'";
            ResultSet rs = statement.executeQuery(sql);
            while (rs.next()){
             String name = rs.getString("m.name");
             System.out.println(name);
            }
            rs.close();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
